#!/usr/bin/env python3

from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration

def generate_launch_description():
    # 声明启动参数
    publish_frequency_arg = DeclareLaunchArgument(
        'publish_frequency',
        default_value='1.0',
        description='Publisher frequency in Hz'
    )

    message_prefix_arg = DeclareLaunchArgument(
        'message_prefix',
        default_value='Hello',
        description='Message prefix for publisher'
    )

    # 创建节点
    publisher_node = Node(
        package='multi_launch_demo',
        executable='publisher_node',
        name='publisher_node',
        parameters=[{
            'publish_frequency': LaunchConfiguration('publish_frequency'),
            'message_prefix': LaunchConfiguration('message_prefix')
        }],
        output='screen'
    )

    subscriber_node = Node(
        package='multi_launch_demo',
        executable='subscriber_node',
        name='subscriber_node',
        output='screen'
    )

    param_node = Node(
        package='multi_launch_demo',
        executable='param_node',
        name='param_node',
        output='screen'
    )

    return LaunchDescription([
        publish_frequency_arg,
        message_prefix_arg,
        publisher_node,
        subscriber_node,
        param_node
    ])
